from machine import Pin
import time

led = Pin(25,Pin.OUT)  #GP25为板载LED
key = Pin(0,Pin.IN,Pin.PULL_UP) #设置GP0为按钮
state = 0


while True:
    if key.value() == 0 :   
        time.sleep_ms(20)   #延迟20毫秒去抖动
        if key.value() == 0 :
            state = not state
            led.value(state)
            while not key.value():
                pass